<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title><?php echo $title;?></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../public/plugin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../public/css/base.css" type="text/css"/>
  <link rel="stylesheet" href="../../public/icon/demo.css">
  <link rel="stylesheet" href="../../public/icon/iconfont.css">
  <script src="../../public/icon/iconfont.js"></script>
  <link rel="stylesheet" href="../../public/icon1/demo.css">
  <link rel="stylesheet" href="../../public/icon1/iconfont.css">
  <script src="../../public/icon1/iconfont.js"></script>
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header" style="padding-top:30px;font-size:18px;"><?php echo $title;?>
			<div style="float:right;padding-right:20px;">
				<button class="layui-btn layui-btn-normal" id="csv"><span class="iconfont icon-tuichu"></span>&nbsp;导出CSV</button>
				<button class="layui-btn layui-btn-normal" id="print"><span class="iconfont icon-dayinji"></span>&nbsp;打印</button>
				<button class="layui-btn layui-btn-normal" id="add"><span class="iconfont icon-plus-circle"></span>&nbsp;增加</button>
			</div>
		  </div>
          <div class="layui-card-body" pad15>
			<table class="layui-table">
			  <thead>
				<tr>
				  <th>id</th>
				  <th>name</th>
				  <th>password</th>
				  <th>加入时间</th>
				  <th>头像</th>
				  <th>操作</th>
				</tr> 
			  </thead>
			  <tbody>
			  <?php foreach($list as $k => $v):?>
				<tr>
				  <td><?php echo $v['id'];?></td>
				  <td><?php echo $v['name'];?></td>
				  <td><?php echo $v['password'];?></td>
				  <td><?php date_default_timezone_set("Asia/Shanghai"); echo date('Y-m-d H:i:s',$v['created_time']);?></td>
				  <td><img src="../../public/uploads/img/<?php echo $v['image'];?>" class="layui-nav-img"></td>
				  <td>
					<div class="layui-btn-container">
					  <button class="layui-btn layui-btn-sm" index="<?php echo $v['id'];?>" onclick="Delete(this)">删除</button> 
					  <button class="layui-btn layui-btn-sm" admin_type="<?php echo $v['id'];?>" onclick="Make(this)">设置管理</button> 
					</div>
				  </td>
				</tr>
				<?php endforeach;?>
				<tr>
					<td colspan="6">
					  <div class="pages">
						<?php echo $strPage;?>
					  </div>
					</td>
				</tr>
			  </tbody>
			</table>
			
          </div>
        </div>
      </div>
    </div>
  </div>
</body>
</html>
<script src="../../public/js/jquery.js"></script>
<script src="../../public/plugin/layer/layer.js"></script>
  <script>
	$(function(){
		$("#csv").click(function(){
			var tx = '<?php echo $title;?>';
			var index = tx.lastIndexOf("\-");
			tx = tx.substring(index+1,tx.length);
			window.location.href="csv.php?tx="+tx;
		});
		//打印
		$("#print").click(function(){
			window.print();
		});
		$("#add").click(function(){
			layer.open({
				type: 2,
				title: '添加考试人员',
				shadeClose: true,
				shade: 0.8,
				area: ['800px', '50%'],
				maxmin: true, //开启最大化最小化按钮
				content: "add_person.php" //iframe的url
			});
		});
	});
  </script>
  
  <script>
	function Delete(btn){
		var index = btn.getAttribute("index");
		var id = Number(index);
		var tr = btn.parentNode.parentNode.parentNode;
		if(confirm('你确定要删除吗？')){
			
			//ajax删除
			$.ajax({
				type: "GET",
				url: "ajaxDeletePerson.php?id="+id,
				success: function(data){
					if(data=='<span style="color:green;">删除成功</span>'){
						layer.msg(data, {icon: 6, time: 2000});
						//移除选中行
						tr.remove();
					}else{
						layer.msg(data, {icon: 5, time: 2000});
					}			
				}
			});
		};
	}
	
	function Make(btn){
		var index = btn.getAttribute("admin_type");
		var id = Number(index);
		var tr = btn.parentNode.parentNode.parentNode;
		if(confirm('你确定要设置他为管理员吗？')){
			
			//ajax设置管理员
			$.ajax({
				type: "GET",
				url: "ajaxAddHeAdmin.php?id="+id,
				success: function(data){
					if(data == '<span style="color:green;">设置成功</span>'){
						layer.msg(data, {icon: 1, time: 2000});
						//移除选中行
						tr.remove();
					}else{
						layer.msg(data, {icon: 2, time: 2000});
					}
				}
			});
		};
	}
  </script>